Skip to content

feat(express): add EdDSA MPCv2 external signer routing#8882

Open
vibhavgo wants to merge 1 commit into
masterfrom
WCI-380
Open

feat(express): add EdDSA MPCv2 external signer routing#8882
vibhavgo wants to merge 1 commit into
masterfrom
WCI-380

Conversation

@vibhavgo
Copy link
Copy Markdown
Contributor

Add Express routing for EdDSA MPCv2 external signer share generation. Wire MPCv2 wallet signing params to use the EdDSA round generators.

  • Route EddsaMPCv2Round1/2/3 share requests to offline helpers
  • Add EdDSA MPCv2 external signer generator factories
  • Add typed route response codecs for EdDSA MPCv2 share responses
  • Cover route dispatch, generator requests, and signing-param wiring
  • Avoid external signer test fixture rewrites during test imports

Ticket: WCI-380

Add Express routing for EdDSA MPCv2 external signer share generation.
Wire MPCv2 wallet signing params to use the EdDSA round generators.

- Route EddsaMPCv2Round1/2/3 share requests to offline helpers
- Add EdDSA MPCv2 external signer generator factories
- Add typed route response codecs for EdDSA MPCv2 share responses
- Cover route dispatch, generator requests, and signing-param wiring
- Avoid external signer test fixture rewrites during test imports

Ticket: WCI-380
@vibhavgo vibhavgo requested review from a team as code owners May 28, 2026 09:14
@vibhavgo vibhavgo requested review from pranavjain97 and ranga-r2 May 28, 2026 09:14
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 28, 2026

WCI-380

@pranavjain97
Copy link
Copy Markdown
Contributor

@claude

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Claude finished @pranavjain97's task —— View job


Code Review Complete ✅

Reviewing the PR changes for EdDSA MPCv2 external signer routing implementation.

Todo List:

  • Read and analyze the changed files
  • Review implementation against PR requirements
  • Check code quality and best practices
  • Verify test coverage
  • Provide comprehensive feedback

Review Summary

This PR successfully implements EdDSA MPCv2 external signer routing by adding support for the three-round EdDSA MPCv2 signing protocol alongside the existing EdDSA v1 protocol. The implementation is well-structured and follows established patterns.

Strengths

1. Comprehensive Implementation

  • Multi-protocol support: Correctly handles both EdDSA v1 (commitment/R/G shares) and EdDSA MPCv2 (Round1/2/3) protocols
  • Proper routing: Routes share requests to appropriate offline helpers based on multisigTypeVersion
  • Complete coverage: Implements all three MPCv2 rounds (EddsaMPCv2Round1, EddsaMPCv2Round2, EddsaMPCv2Round3)

2. Code Quality & Architecture

  • Consistent patterns: New generator functions follow the exact same structure as existing ECDSA MPCv2 generators
  • Proper abstractions: Uses EddsaMPCv2Utils class for cryptographic operations
  • Type safety: Comprehensive type definitions in generateShareTSS.ts with detailed documentation
  • URL construction: Consistent REST endpoint patterns (/api/v2/{coin}/tssshare/EddsaMPCv2Round{1|2|3})

3. Backward Compatibility

  • Non-breaking: EdDSA v1 functionality remains unchanged
  • Version detection: Uses wallet._wallet.multisigTypeVersion === 'MPCv2' for proper routing
  • Graceful fallbacks: Maintains existing behavior for non-MPCv2 wallets

4. Excellent Test Coverage

  • Unit tests: 273 new test lines covering all three rounds
  • Integration tests: End-to-end MPCv2 flow with real cryptographic operations
  • Edge cases: Tests for unsupported share types and error handling
  • Network mocking: Proper HTTP client testing with nock
  • Backward compatibility: Tests ensure v1 generators still work

🔍 Technical Review

clientRoutes.ts (Lines 461-497)

const isMPCv2 = [
  ShareType.EddsaMPCv2Round1.toString(),
  ShareType.EddsaMPCv2Round2.toString(), 
  ShareType.EddsaMPCv2Round3.toString(),
].includes(req.decoded.sharetype) || req.decoded.sharetype.startsWith('EddsaMPCv2');

Good: Robust MPCv2 detection with both enum matching and string prefix matching

External Signer Routing (Lines 924-951)

if (wallet._wallet.multisigTypeVersion === 'MPCv2') {
  return {
    ...req.body,
    customEddsaMPCv2SigningRound1GenerationFunction: createCustomEddsaMPCv2SigningRound1Generator(/*...*/),
    customEddsaMPCv2SigningRound2GenerationFunction: createCustomEddsaMPCv2SigningRound2Generator(/*...*/),
    customEddsaMPCv2SigningRound3GenerationFunction: createCustomEddsaMPCv2SigningRound3Generator(/*...*/),
  };
}

Good: Clear separation between MPCv2 and v1 generator assignment

Generator Functions (Lines 1824-1867)

Good: Identical structure to ECDSA MPCv2 generators with proper error handling and retry logic

📝 Minor Suggestions

1. Error Message Consistency

The EdDSA MPCv2 error message could match the ECDSA format:

// Current (line 480)
`Share type ${req.decoded.sharetype} not supported for EdDSA MPCv2, only EddsaMPCv2Round1, EddsaMPCv2Round2 and EddsaMPCv2Round3 is supported.`

// Suggested (matches ECDSA format on line 516)  
`Share type ${req.decoded.sharetype} not supported for EdDSA MPCv2, only EddsaMPCv2Round1, EddsaMPCv2Round2 and EddsaMPCv2Round3 are supported.`

2. Type Documentation Enhancement

The type definitions are excellent, but consider adding examples for better developer experience:

/**
 * @example
 * // EdDSA MPCv2 Round 1 request
 * POST /api/v2/tsol/tssshare/EddsaMPCv2Round1
 * {
 *   "txRequest": { "walletId": "...", "transactions": [...] }
 * }
 */

🚀 Recommendation: APPROVE

This is a high-quality implementation that:

  • Meets all PR requirements (routes EddsaMPCv2Round1/2/3, adds generator factories, covers dispatch and signing-param wiring)
  • Follows established patterns consistently
  • Maintains backward compatibility
  • Has comprehensive test coverage including edge cases
  • Uses proper error handling and type safety
  • Is production-ready with no security concerns identified

The implementation demonstrates solid understanding of the existing codebase architecture and cryptographic protocols. The minor suggestions above are optional enhancements that don't block approval.


Job Run: View workflow run

@Marzooqa Marzooqa self-requested a review June 2, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants